package net.csdn.business.common.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.util.Map;

/**
 * @author likun
 * @date 2022/6/6 17:57
 */
@Getter
@AllArgsConstructor
public enum ResultCodeEnum {
    /**
     * 成功
     */
    OK(200, "success", "MESSAGE.OK", HttpStatus.OK),
    SUCCESS(200, "success", "MESSAGE.SUCCESS", HttpStatus.OK),
    BAD_REQUEST(400, "Bad Request", "MESSAGE.BAD_REQUEST", HttpStatus.BAD_REQUEST),
    USER_PWD_ERROR(401, "账号或者密码错误", "MESSAGE.USER_PWD_ERROR", HttpStatus.UNAUTHORIZED),
    UNAUTHORIZED(403, "操作失败，暂无权限", "MESSAGE.UNAUTHORIZED", HttpStatus.FORBIDDEN),
    FEIGN_UNAUTHORIZED(403, "请求失败，feign请求token有误", "MESSAGE.FEIGN_UNAUTHORIZED", HttpStatus.FORBIDDEN),
    RESOURCE_NOT_EXIST(404, "资源不存在", "MESSAGE.RESOURCE_NOT_EXIST", HttpStatus.NOT_FOUND),
    NOT_PATH(404, "路径不存在", "MESSAGE.RESOURCE_NOT_EXIST", HttpStatus.NOT_FOUND),
    METHOD_NOT_ALLOWED(406, "Method Not Allowed", "MESSAGE.METHOD_NOT_ALLOWED", HttpStatus.METHOD_NOT_ALLOWED),


    FAIL(500, "系统错误", "MESSAGE.FAIL", HttpStatus.INTERNAL_SERVER_ERROR),
    UN_KNOW(500, "未知错误", "MESSAGE.FAIL", HttpStatus.BAD_REQUEST),
    THIRD_ERROR(999, "接口错误，稍后重试", "MESSAGE.THIRD_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    PARAMETER_ERROR(1000, "参数错误", "MESSAGE.PARAMETER_ERROR", HttpStatus.BAD_REQUEST),
    PARAMETER_ERROR_CUSTOM(1000, "%s参数错误", "MESSAGE.PARAMETER_ERROR_CUSTOM", HttpStatus.BAD_REQUEST),
    ILLEGAL_OPERATION(1001, "非法操作", "MESSAGE.ILLEGAL_OPERATION", HttpStatus.BAD_REQUEST),
    NOT_EXIST(1002, "资源不存在", "MESSAGE.NOT_EXIST", HttpStatus.NOT_FOUND),
    EMAIL_TEMPLATE_NOTE_EXIST(1003, "%s通知模板不存在", "MESSAGE.EMAIL_TEMPLATE_NOTE_EXIST", HttpStatus.BAD_REQUEST),
    AUTHING_ERROR(1004, "authing服务出错", "MESSAGE.AUTHING_ERROR", HttpStatus.BAD_REQUEST),
    NOTICE_YUN_ERROR(1005, "通知云效服务出错", "MESSAGE.NOTICE_YUN_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),

    NOTNULL(1006, "%s不能为空", "MESSAGE.NOTNULL", HttpStatus.BAD_REQUEST),
    INVALID_VER_CODE(1007, "验证码不正确或已过期", "MESSAGE.INVALID_VER_CODE", HttpStatus.BAD_REQUEST),
    SEND_VER_CODE_ERROR(1007, "验证码发送失败", "MESSAGE.SEND_VER_CODE_ERROR", HttpStatus.BAD_REQUEST),

    INVITATION_NOT_EXIST(1008, "邀请不存在", "MESSAGE.INVITATION_NOT_EXIST", HttpStatus.NOT_FOUND),
    ENCRYPT_KEY_ERROR(1009, "加密key未设置，请检查配置", "MESSAGE.ENCRYPT_KEY_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ENCRYPT_IV_ERROR(1010, "加密iv偏移量有误", "MESSAGE.ENCRYPT_IV_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),


    /**
     * 评论相关 1020 - 1029
     */
    NOT_COMMENT(1020, "不能评论", "MESSAGE.NOT_COMMENT", HttpStatus.BAD_REQUEST),
    ISSUE_ASSIGN_USER_PERMISSION(1021, "assignUser 权限异常", "MESSAGE.ISSUE_ASSIGN_USER_PERMISSION", HttpStatus.BAD_REQUEST),
    ISSUE_MOVE_PROJECT(1022, "projectId不能相同", "MESSAGE.ISSUE_MOVE_PROJECT", HttpStatus.BAD_REQUEST),
    NOT_MODIFY_COMMENT(1023, "评论不能修改", "MESSAGE.NOT_MODIFY_COMMENT", HttpStatus.BAD_REQUEST),

    /**
     * 配置相关 1030 - 1039
     */
    CONFIG_ERROR(1030, "%s配置错误", "MESSAGE.CONFIG_ERROR", HttpStatus.BAD_REQUEST),
    OPERATE_NAME_EXIST_ERROR(1031, "名称已存在", "MESSAGE.OPERATE_NAME_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    OPERATE_OBJECT_EXIST_ERROR(1032, "推荐主体已存在", "MESSAGE.OPERATE_OBJECT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    COMMON_CONFIG_EXIST_ERROR(1033, "公共配置类型已存在", "MESSAGE.COMMON_CONFIG_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    COMMON_CONFIG_DELETE_SYSTEM_ERROR(1034, "系统公共配置不能删除", "MESSAGE.COMMON_CONFIG_DELETE_SYSTEM_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 用户相关 420 - 449
     */
    NOT_LOGIN_ERROR(420, "未认证或已过期", "MESSAGE.NOT_LOGIN_ERROR", HttpStatus.UNAUTHORIZED),
    CODE_INVALID_ERROR(421, "code码无效", "MESSAGE.CODE_INVALID_ERROR", HttpStatus.BAD_REQUEST),
    REFRESH_TOKEN_INVALID_ERROR(422, "refreshToken无效", "MESSAGE.REFRESH_TOKEN_INVALID_ERROR", HttpStatus.BAD_REQUEST),
    USER_NOT_EXIST_ERROR(423, "用户不存在", "MESSAGE.USER_NOT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    TWO_PWD_NOT_MATCH(424, "两次输入密码不一致", "MESSAGE.TWO_PWD_NOT_MATCH", HttpStatus.BAD_REQUEST),
    ORI_PWD_ERROR(425, "原始密码不正确", "MESSAGE.ORI_PWD_ERROR", HttpStatus.BAD_REQUEST),
    BIND_REPEAT_ERROR(426, "不能重复绑定", "MESSAGE.BIND_REPEAT_ERROR", HttpStatus.BAD_REQUEST),
    MAIN_EMAIL_DEL(427, "主邮箱不允许删除", "MESSAGE.MAIN_EMAIL_DEL", HttpStatus.BAD_REQUEST),
    FANS_REPEAT_ERROR(428, "不能重复关注", "MESSAGE.FANS_REPEAT_ERROR", HttpStatus.BAD_REQUEST),
    USERNAME_EMPTY_ERROR(429, "用户名不存在", "MESSAGE.USERNAME_EMPTY_ERROR", HttpStatus.BAD_REQUEST),
    USERNAME_EXISTS_ERROR(430, "该用户名已被注册", "MESSAGE.USERNAME_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    EMAIL_EXISTS_ERROR(431, "该邮箱已被绑定", "MESSAGE.EMAIL_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    PHONE_EXISTS_ERROR(432, "该手机号已被绑定", "MESSAGE.PHONE_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    IP_LIMIT_ERROR(433, "未在IP白名单内", "MESSAGE.IP_LIMIT_ERROR", HttpStatus.BAD_REQUEST),
    NOT_PASSWD(434, "暂未设置密码，不允许操作", "MESSAGE.NOT_PASSWD", HttpStatus.BAD_REQUEST),
    INVALID_PASSWD(435, "请使用至少 6 位字符作为密码，须包含英文、数字与符号中的两种", "MESSAGE.INVALID_PASSWD", HttpStatus.BAD_REQUEST),
    USER_MFA_SECRET_EXPIRE(436, "secret过期，请刷新二维码页面重新绑定", "MESSAGE.USER_MFA_SECRET_EXPIRE", HttpStatus.BAD_REQUEST),
    USER_MFA_VERIFI_CODE_ERROR(437, "验证码错误，请重新输入", "MESSAGE.USER_MFA_VERIFI_CODE_ERROR", HttpStatus.BAD_REQUEST),
    USER_MFA_VERIFI_PASSWORD_ERROR(438, "密码错误，请重新输入", "MESSAGE.USER_MFA_VERIFI_PASSWORD_ERROR", HttpStatus.BAD_REQUEST),
    OTHER_USER_STARTED_ERROR(439, "用户star列表获取失败", "MESSAGE.OTHER_USER_STARTED_ERROR", HttpStatus.BAD_REQUEST),
    ACCOUNT_BIND_ERROR(440, "绑定失败，是否合并到该主账号？", "MESSAGE.ACCOUNT_BIND_ERROR", HttpStatus.BAD_REQUEST),
    USER_NO_EXIST_ERROR(441, "用户不存在", "MESSAGE.USER_NO_EXIST_ERROR", HttpStatus.NOT_FOUND),
    USER_TOKEN_ERROR(442, "token无效,获取用户信息失败", "MESSAGE.USER_TOKEN_ERROR", HttpStatus.UNAUTHORIZED),
    USER_MFA_VERIFI_RECOVERY_ERROR(443, "恢复码错误，请重新输入", "MESSAGE.USER_MFA_VERIFI_RECOVERY_ERROR", HttpStatus.BAD_REQUEST),
    USER_NEED_MFA_VERIFI(444, "请求失败，请进行mfa验证", "MESSAGE.USER_NEED_MFA_VERIFI", HttpStatus.FORBIDDEN),
    USER_MFA_CLOSE_ERROR(445, "用户MFA已关闭", "MESSAGE.USER_MFA_CLOSE_ERROR", HttpStatus.BAD_REQUEST),
    USER_DENY_SELF_OPERATE_ERROR(446, "操作失败，禁止对自己进行操作", "MESSAGE.USER_DENY_SELF_OPERATE_ERROR", HttpStatus.BAD_REQUEST),
    USER_SCORE_ACTION_RULE_ERROR(447, "操作失败，用户ACTION计算参数有误", "MESSAGE.USER_SCORE_ACTION_RULE_ERROR", HttpStatus.BAD_REQUEST),
    USER_SCORE_RANK_TYPE_ERROR(448, "操作失败，用户排行榜枚举有误", "MESSAGE.USER_SCORE_RANK_TYPE_ERROR", HttpStatus.BAD_REQUEST),
    USER_BLACK_ADD_ERROR(449, "操作失败，用户黑名单已存在", "MESSAGE.USER_BLACK_ADD_ERROR", HttpStatus.BAD_REQUEST),
    USER_CAL_RULE_COUNT_EXCEED_ERROR(450, "操作失败，积分计算规则不能超过10个，防止对系统存储产生较大压力", "MESSAGE.USER_CAL_RULE_COUNT_EXCEED_ERROR", HttpStatus.BAD_REQUEST),
    USER_CAL_SCORE_TASK_ERROR(451, "操作失败，积分计算任务进行中，请稍后重试", "MESSAGE.USER_CAL_SCORE_TASK_RUNNING_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 审核相关 460-469
     */
    CONTENT_CHECK_ERROR(460, "内容审核中,暂不可见", "MESSAGE.CONTENT_CHECK_ERROR", HttpStatus.BAD_REQUEST),
    CONTENT_CHECK_PARAMETER_ERROR(469, "%s", "MESSAGE.CONTENT_CHECK_PARAMETER_ERROR", HttpStatus.BAD_REQUEST),
    CONTAIN_SENSITIVE_WORD_ERROR(467, "搜索关键字包含敏感词", "MESSAGE.CONTAIN_SENSITIVE_WORD_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 重复提交
     */
    REPEAT_SUBMIT_ERROR(450, "重复提交", "MESSAGE.REPEAT_SUBMIT_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 组织相关
     */
    ORG_USER_NO_EXIST_ERROR(600, "参参数有误，该组织下不存在此用户", "MESSAGE.ORG_USER_NO_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    QUIT_ORG_USER_ONLY_ONE_ERROR(601, "暂不允许退出，组织至少需要一位管理员，请添加其他管理员后再试", "MESSAGE.QUIT_ORG_USER_ONLY_ONE_ERROR", HttpStatus.BAD_REQUEST),
    QUIT_ORG_USER_COUNT_ZERO_ERROR(602, "暂不允许更新角色，组织至少需要一位管理员！", "MESSAGE.QUIT_ORG_USER_COUNT_ZERO_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_MEMBER_EXIST_ERROR(603, "被邀请用户已存在", "MESSAGE.INVITE_MEMBER_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_MEMBER_ERROR(604, "被邀请用户出错，请重试", "MESSAGE.INVITE_MEMBER_ERROR", HttpStatus.BAD_REQUEST),
    ORG_NO_EXIST_ERROR(404, "组织不存在", "MESSAGE.ORG_NO_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    DELETE_ORG_ERROR(605, "删除组织失败", "MESSAGE.DELETE_ORG_ERROR", HttpStatus.BAD_REQUEST),
    ORG_IS_EXIST_ERROR(606, "组织已存在", "MESSAGE.ORG_IS_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    ORG_CREATE_NUM_LIMIT_ERROR(607, "组织创建数量已达上限", "MESSAGE.ORG_CREATE_NUM_LIMIT_ERROR", HttpStatus.BAD_REQUEST),
    ORG_INFO_VALIDATION_FAILED_ERROR(608, "组织关联信息验证失败", "MESSAGE.ORG_CREATE_NUM_LIMIT_ERROR", HttpStatus.UNPROCESSABLE_ENTITY),
    INVITE_MEMBER_DENY_ERROR(609, "邀请失败，暂无邀请权限", "MESSAGE.INVITE_MEMBER_DENY_ERROR", HttpStatus.FORBIDDEN),
    ORG_MEMBER_NOTEXIST_ERROR(610, "组织成员不存在", "MESSAGE.ORG_MEMBER_NOTEXIST_ERROR", HttpStatus.NOT_FOUND),
    ORG_REQUESTER_NOT_MEMBER_ERROR(611, "当前操作用户非组织成员", "MESSAGE.ORG_REQUESTER_NOT_MEMBER_ERROR", HttpStatus.FORBIDDEN),
    ORG_MEMBER_DELETE_SELF_ERROR(612, "组织成员不能移除自己", "MESSAGE.ORG_MEMBER_DELETE_SELF_ERROR", HttpStatus.FORBIDDEN),
    ORG_MEMBER_DELETE_ERROR(613, "移除失败，暂无权限", "MESSAGE.ORG_MEMBER_DELETE_ERROR", HttpStatus.FORBIDDEN),
    ORG_NOT_EXIST_ERROR(614, "组织不存在", "MESSAGE.ORG_NOT_EXIST_ERROR", HttpStatus.NOT_FOUND),
    ORG_SET_MEMBER_ROLE_DENY_ERROR(615, "操作失败，暂无权限", "MESSAGE.ORG_SET_MEMBER_ROLE_DENY_ERROR", HttpStatus.FORBIDDEN),
    ORG_REMOVE_MEMBER_ERROR(616, "移除组织成员失败", "MESSAGE.ORG_REMOVE_MEMBER_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_CREATE_ERROR(617, "组织创建失败", "MESSAGE.ORG_CREATE_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_UPDATE_ERROR(618, "组织信息更新失败", "MESSAGE.ORG_UPDATE_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_MEMEBER_SET_ROLE_ERROR(619, "组织角色设置失败", "MESSAGE.ORG_MEMEBER_SET_ROLE_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_UPDATE_AUDIT_STATUS_ERROR(620, "组织更新审核状态失败", "MESSAGE.ORG_UPDATE_AUDIT_STATUS_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_MEMBER_QUIT_ERROR(621, "组织成员退出失败", "MESSAGE.ORG_MEMBER_QUIT_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    ORG_UPDATE_DENY_ERROR(622, "组织信息更新失败,暂无权限", "MESSAGE.ORG_UPDATE_DENY_ERROR", HttpStatus.FORBIDDEN),
    ORG_BATCH_QUERY_ERROR(623, "批量查询组织信息最大上限是50条", "MESSAGE.ORG_BATCH_QUERY_ERROR", HttpStatus.BAD_REQUEST),
    ORG_CREATE_DENY_ERROR(625, "组织创建失败,暂无权限", "MESSAGE.ORG_CREATE_DENY_ERROR", HttpStatus.FORBIDDEN),

    /**
     * 子组织相关
     */
    ORG_RELATION_NO_EXIST_ERROR(691, "操作失败，组织关联关系不存在", "MESSAGE.ORG_RELATION_NO_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    ORG_RELATION_REMOVE_DENY_ERROR(691, "操作失败，暂无权限", "MESSAGE.ORG_RELATION_REMOVE_DENY_ERROR", HttpStatus.FORBIDDEN),
    ORG_MAINTAINER_NOT_EXIST_ERROR(692, "操作失败，被关联组织不存在maintainer", "MESSAGE.ORG_MAINTAINER_NOT_EXIST_ERROR", HttpStatus.FORBIDDEN),
    ORG_LAUNCH_EXIST_PARENT_RELATION_ERROR(693, "向上关联失败，组织关联发起方存在父关联组织", "MESSAGE.ORG_LAUNCH_EXIST_PARENT_RELATION_ERROR", HttpStatus.BAD_REQUEST),
    ORG_TARGET_EXIST_PARENT_RELATION_ERROR(694, "向下关联失败，组织被关联方存在父组织关系", "MESSAGE.ORG_TARGET_EXIST_PARENT_RELATION_ERROR", HttpStatus.BAD_REQUEST),
    ORG_RELATED_EXIST_RELATION_ERROR(695, "关联申请失败，发起组织与被关联组织存在关联关系", "MESSAGE.ORG_RELATED_EXIST_RELATION_ERROR", HttpStatus.BAD_REQUEST),
    ORG_RELATION_PARENT_EXIST_ERROR(696, "关联失败，子组织存在多个父组织", "MESSAGE.ORG_RELATION_PARENT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    //ORG_RELATED_MAINTAINER_EMAIL_ERROR(697, "发起关联失败，被关联方组织管理员暂未设置邮箱", "MESSAGE.ORG_RELATED_MAINTAINER_EMAIL_ERROR", HttpStatus.BAD_REQUEST),


    /**
     * 命名空间相关
     */
    NAME_SPACE_NOT_EXIST_ERROR(700, "命名空间不存在", "MESSAGE.NAME_SPACE_NOT_EXIST_ERROR", HttpStatus.NOT_FOUND),
    NAME_SPACE_EXIST_ERROR(701, "命名空间已经存在", "MESSAGE.NAME_SPACE_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    NAME_SPACE_NOT_AUTH_ERROR(702, "暂未授权此命名空间", "MESSAGE.NAME_SPACE_NOT_AUTH_ERROR", HttpStatus.BAD_REQUEST),
    NAME_SPACE_NOT_VALID_ERROR(703, "命名空间不合法", "MESSAGE.NAME_SPACE_NOT_VALID_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 项目相关
     */
    SELECTED_PROJECT_EXIST_ERROR(801, "操作失败，精选项目已存在", "MESSAGE.SELECTED_PROJECT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    SELECTED_PROJECT_NOT_EXIST_ERROR(801, "操作失败，精选项目不存在", "MESSAGE.SELECTED_PROJECT_NOT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    PROJECT_NOT_EXIST_ERROR(801, "项目不存在", "MESSAGE.PROJECT_NOT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 举报相关
     */
    REPORT_REPEAT_ERROR(901, "请稍后再进行举报", "MESSAGE.REPORT_REPEAT_ERROR", HttpStatus.BAD_REQUEST),

    /**
     * CLA相关 1040-1049
     */
    CLA_NOT_EXISTS_ERROR(1040, "CLA协议不存在", "MESSAGE.CLA_NOT_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    CLA_REPO_NULL_ERROR(1041, "CLA协议未选择关联仓库", "MESSAGE.CLA_REPO_NULL_ERROR", HttpStatus.BAD_REQUEST),
    CLA_REPO_EXISTS_ERROR(1042, "所选仓库已被其他CLA协议关联", "MESSAGE.CLA_REPO_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    CLA_VERSION_EXISTS_ERROR(1043, "版本已存在", "MESSAGE.CLA_VERSION_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    CLA_SIGN_NOT_EXISTS_ERROR(1044, "CLA签署不存在", "MESSAGE.CLA_VERSION_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    CLA_SIGN_REPEAT_ERROR(1045, "CLA已签署", "MESSAGE.CLA_VERSION_EXISTS_ERROR", HttpStatus.BAD_REQUEST),

    /**
     * 标签、里程碑相关 1050-1059
     */
    LABEL_NOT_EXISTS_ERROR(1050, "标签不存在", "MESSAGE.LABEL_NOT_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    LABEL_NAME_EXISTS_ERROR(1051, "标签名称已存在", "MESSAGE.LABEL_NAME_EXISTS_ERROR", HttpStatus.BAD_REQUEST),

    MILEPOST_NOT_EXISTS_ERROR(1052, "里程碑不存在", "MESSAGE.MILEPOST_NOT_EXISTS_ERROR", HttpStatus.BAD_REQUEST),
    MILEPOST_NAME_EXISTS_ERROR(1053, "里程碑名称已存在", "MESSAGE.MILEPOST_NAME_EXISTS_ERROR", HttpStatus.BAD_REQUEST),

    /**
     * oauth应用相关 1100-1149
     */
    OAUTH_CLIENT_ID_ERROR(1100, "clientId有误", "MESSAGE.OAUTH_CLIENT_ID_ERROR", HttpStatus.BAD_REQUEST),
    OAUTH_ACESS_TOKEN_ID_ERROR(1101, "tokenId有误", "MESSAGE.OAUTH_ACESS_TOKEN_ID_ERROR", HttpStatus.BAD_REQUEST),
    OAUTH_CLIENT_REVOKE_ALL_ERROR(1102, "撤销失败，暂无权限", "MESSAGE.OAUTH_CLIENT_REVOKE_ALL_ERROR", HttpStatus.BAD_REQUEST),
    OAUTH_PERSON_TOKEN_ADD_ERROR(1103, "私人token添加失败", "MESSAGE.OAUTH_PERSON_TOKEN_ERROR", HttpStatus.BAD_REQUEST),
    OAUTH_PERSON_TOKEN_REMOVE_ERROR(1104, "私人token删除失败", "MESSAGE.OAUTH_PERSON_TOKEN_ERROR", HttpStatus.BAD_REQUEST),
    OAUTH_INVALID_REQUEST_ERROR(1105, "授权链接无效,授权失败", "MESSAGE.OAUTH_INVALID_REQUEST_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 网关相关 1150-1199
     */
    GATEWAY_ROUTE_ID_EXIST_ERROR(1151, "routeId有误，已存在", "MESSAGE.GATEWAY_ROUTE_ID_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    GATEWAY_ROUTE_NO_EXIST_ERROR(1152, "参数有误，路由信息不存在", "MESSAGE.GATEWAY_ROUTE_ID_EXIST_ERROR", HttpStatus.BAD_REQUEST),

    /**
     * 镜像相关 1200-1249
     */
    MIRROR_DATA_NOT_EXIST_ERROR(1200, "镜像数据已删除", "MESSAGE.MIRROR_DATA_NOT_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    MIRROR_DATA_BLACKED(1201, "镜像数据已加入黑名单", "MESSAGE.MIRROR_DATA_BLACKED", HttpStatus.BAD_REQUEST),
    MIRROR_DATA_NOT_IMPORT(1202, "镜像数据还未导入", "MESSAGE.MIRROR_DATA_NOT_IMPORT", HttpStatus.BAD_REQUEST),
    MIRROR_GITHUB_TOKEN_EMPTY(1203, "请调整GithubToken相关配置", "MESSAGE.MIRROR_GITHUB_TOKEN_EMPTY", HttpStatus.BAD_REQUEST),
    MIRROR_GITHUB_REPOSITORY_ERROR(1204, "获取Github相关接口出错", "MESSAGE.MIRROR_GITHUB_REPOSITORY_ERROR", HttpStatus.BAD_REQUEST),
    MIRROR_IMPORT_RETRY_STATUS_ERROR(1205, "该状态暂不允许重试", "MESSAGE.MIRROR_IMPORT_RETRY_STATUS_ERROR", HttpStatus.BAD_REQUEST),
    MIRROR_GITHUB_TOKEN_INVALID(1206, "token不可用或已过期,请更换", "MESSAGE.MIRROR_GITHUB_TOKEN_INVALID", HttpStatus.BAD_REQUEST),
    MIRROR_CONFIG_FORBID(1207, "操作失败，暂无权限", "MESSAGE.MIRROR_CONFIG_FORBID", HttpStatus.FORBIDDEN),
    IMPORT_RETRY_ERROR(1208, "重试失败，项目已存在，请更换命名空间", "MESSAGE.IMPORT_RETRY_ERROR", HttpStatus.BAD_REQUEST),
    IMPORT_UPLOAD_IMPORT_ERROR(1209, "操作失败，请检查导入数据", "MESSAGE.IMPORT_UPLOAD_IMPORT_ERROR", HttpStatus.BAD_REQUEST),

    /**
     * openApi相关 1250-1500
     */
    OPEAN_API_DENY(1251, "请求失败，暂无权限", "MESSAGE.OPEAN_API_DENY", HttpStatus.FORBIDDEN),
    INVALID_TOKEN(1252, "无效的token", "MESSAGE.INVALID_TOKEN", HttpStatus.UNAUTHORIZED),
    ISSUE_NOT_EXIST(1253, "issue不存在", "MESSAGE.ISSUE_NOT_EXIST", HttpStatus.BAD_REQUEST),
    DATE_FORMATE_FAIL(1254,"日期格式不正确", "MESSAGE.DATE_FORMATE_FAIL", HttpStatus.BAD_REQUEST),
    API_USER_NOT_EXIST_ERROR(1255, "用户不存在", "MESSAGE.API_USER_NOT_EXIST_ERROR", HttpStatus.NOT_FOUND),
    API_ORG_NOT_EXIST_ERROR(1256, "组织不存在", "MESSAGE.API_ORG_NOT_EXIST_ERROR", HttpStatus.NOT_FOUND),

    /**
     * webhook相关 1600-1650
     */
    WEB_HOOK_ENCRYPT_KEY_ERROR(1600, "加密key未设置，请检查配置", "MESSAGE.WEB_HOOK_ENCRYPT_KEY_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    WEB_HOOK_ENCRYPT_IV_ERROR(1601, "加密iv偏移量有误", "MESSAGE.WEB_HOOK_ENCRYPT_IV_ERROR", HttpStatus.INTERNAL_SERVER_ERROR),
    WEB_HOOK_REDELIVERY_NO_EXIST_ERROR(1602, "webhook重试失败，相关webhook配置不存在", "MESSAGE.WEB_HOOK_REDELIVERY_NO_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    WEB_HOOK_REDELIVERY_NO_ACTIVE_ERROR(1603, "webhook重试失败，相关webhook配置未激活", "MESSAGE.WEB_HOOK_REDELIVERY_NO_ACTIVE_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * pages相关 1651-1700
     */
    PAGES_NO_PUBLIC_ERROR(1651, "当前项目为私有项目，设置失败，Pages只支持公开项目操作", "MESSAGE.PAGES_NO_PUBLIC_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 讨论相关3001-3049
     */
    DISCUSS_CATEGORY_NO_EXIST_ERROR(3001,"讨论分类不存在","MESSAGE.DISCUSS_CATEGORY_NO_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_ILLEGAL_ERROR(3002,"操作失败，暂无权限","MESSAGE.DISCUSS_COMMENT_ILLEGAL_ERROR", HttpStatus.FORBIDDEN),
    DISCUSS_REMARK_REPATE_ERROR(3003,"操作失败，重复操作","MESSAGE.DISCUSS_REMARK_REPATE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_NO_EXIST_ERROR(3004,"操作失败，讨论不存在","MESSAGE.DISCUSS_REMARK_REPATE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_CLOSE_ERROR(3005,"操作失败，讨论已关闭","MESSAGE.DISCUSS_REMARK_REPATE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_CATEGORY_UP_LIMIT_ERROR(3006,"操作失败，讨论分类数量超过限制","MESSAGE.DISCUSS_CATEGORY_UP_LIMIT_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_POLL_DISABLE_CHANGE_ERROR(3007,"操作失败，投票类型的讨论不允许修改为非投票类型","MESSAGE.DISCUSS_POLL_DISABLE_CHANGE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_VOTE_REPATE_ERROR(3008,"投票失败，重复投票","MESSAGE.DISCUSS_VOTE_REPATE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_VOTE_CHANGE_ONE_ERROR(3009,"投票失败，投票只允许修改一次","MESSAGE.DISCUSS_VOTE_CHANGE_ONE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_LOCK_ERROR(3010,"操作失败，讨论已经锁定","MESSAGE.DISCUSS_LOCK_VOTE_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_CATEGORY_CHANGE_POLL_ERROR(3011,"操作失败，非投票类型的讨论不允许修改为投票类型","MESSAGE.DISCUSS_CATEGORY_CHANGE_POLL_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_SECTION_NAME_EXIST_ERROR(3012,"操作失败，分组名称已存在","MESSAGE.DISCUSS_SECTION_NAME_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_CATEGORY_NAME_EXIST_ERROR(3013,"操作失败，分类名称已存在","MESSAGE.DISCUSS_SECTION_NAME_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_REMARK_ANSWER_ERROR(3014,"操作失败，此评论已删除，不能采纳为答案","MESSAGE.DISCUSS_REMARK_ANSWER_ERROR", HttpStatus.BAD_REQUEST),
    DISCUSS_AUDIT_FAIL_ERROR(3015,"讨论不存在","MESSAGE.DISCUSS_AUDIT_FAIL_ERROR",HttpStatus.NOT_FOUND),
    /**
     * 邀请链接相关3050-3099
     */
    INVITE_LINK_EXPIRE_ERROR(3050,"邀请链接已失效","MESSAGE.INVITE_LINK_EXPIRE_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_LINK_APPLY_REPEAT_ERROR(3051,"等待管理员审核中，请勿重复申请","MESSAGE.INVITE_LINK_APPLY_REPEAT_ERROR", HttpStatus.FORBIDDEN),
    INVITE_LINK_USER_EXIST_ERROR(3052,"成员列表中已存在当前用户，无需申请","MESSAGE.INVITE_LINK_USER_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_LINK_APPLY_AUDIT_STATUS_ERROR(3053,"用户申请已审批,请勿重复操作","MESSAGE.INVITE_LINK_APPLY_AUDIT_STATUS_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_LINK_OPERATE_DENY_ERROR(3054,"操作失败，暂无权限","MESSAGE.INVITE_LINK_OPERATE_DENY_ERROR", HttpStatus.FORBIDDEN),
    INVITE_LINK_APPLY_EXPIRE_ERROR(3055,"操作失败，成员申请已过期","MESSAGE.INVITE_LINK_APPLY_EXPIRE_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_LINK_EXPIRE_DATE_ERROR(3056,"操作失败，邀请链接过期时间不能比成员申请的过期时间晚","MESSAGE.INVITE_LINK_APPLY_EXPIRE_ERROR", HttpStatus.BAD_REQUEST),
    INVITE_LINK_INDEX_APPLY_ERROR(3057,"操作失败，首页邀请链接暂未开启","MESSAGE.INVITE_LINK_INDEX_APPLY_ERROR", HttpStatus.FORBIDDEN),
    /**
     * 通知中心相关3200-3499
     */
    NOTIFY_BUSSINESS_CODE_EXIST_ERROR(3201,"业务编码已存在","MESSAGE.NOTIFY_BUSSINESS_CODE_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_BUSSINESS_DELETE_ERROR(3202,"删除业务编码失败，请先删除此业务编码下的通知模板","MESSAGE.NOTIFY_BUSSINESS_DELETE_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_TEMPLATE_EXIST_ERROR(3203,"操作失败,此通道模板已存在","MESSAGE.NOTIFY_TEMPLATE_EXIST_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_ANNOUNCE_RECEIVER_ERROR(3204,"操作失败,接收人不能为空","MESSAGE.NOTIFY_ANNOUNCE_RECEIVER_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_BUSSINESS_CHANNEL_ERROR(3205,"操作失败,私信类型的通知业务不允许添加其他渠道的通知","MESSAGE.NOTIFY_BUSSINESS_CHANNEL_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_NOT_ENABLE_SEND_MSG_ERROR(3206,"发送失败，该用户关闭了私信功能","MESSAGE.NOTIFY_NOT_ENABLE_SEND_MSG_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_SEND_MSG_EXCEED_LIMIT_ERROR(3207,"发送失败，私信发送过于频繁，请稍后重试","MESSAGE.NOTIFY_SEND_MSG_EXCEED_LIMIT_ERROR", HttpStatus.BAD_REQUEST),
    NOTIFY_SEND_MSG_TO_SELF_ERROR(3208,"发送失败，不能给本人自己发送私信","MESSAGE.NOTIFY_SEND_MSG_TO_SELF_ERROR", HttpStatus.BAD_REQUEST),
    /**
     * 仓库打赏相关3500-3550
     */
    REPO_TIPS_DENY_ERROR(3500,"操作失败，暂无权限","MESSAGE.REPO_TIPS_DENY_ERROR", HttpStatus.FORBIDDEN),
    REPO_TIPS_USER_NOT_EXIST_ERROR(3501,"操作失败，捐赠人用户名不存在","MESSAGE.REPO_TIPS_USER_NOT_EXIST_ERROR", HttpStatus.BAD_REQUEST),


    /**
     * 导入相关的异常 4000开头
     */
    MIGRATE_USER_EXIST(4000,"迁移的导入用户已存在","MESSAGE.MIGRATE_USER_EXIST",HttpStatus.BAD_REQUEST),
    //MIGRATE_API_USER_EXIST(409, "MIGRATE_API_USER_EXIST", "MESSAGE.MIGRATE_API_USER_EXIST", HttpStatus.CONFLICT),

    /**
     * actions相关的异常7000开头
     */
    ACTIONS_NOT_EXIST(7000,"操作失败，该记录不存在","MESSAGE.ACTIONS_NOT_EXIST", HttpStatus.BAD_REQUEST),
    ACTIONS_APP_FAIL(7001,"流水线开启失败","MESSAGE.ACTIONS_APP_FAIL", HttpStatus.BAD_REQUEST),
    ACTIONS_NAMESPACE_NOT_EXIST(7002,"流水线命名空间不存在","MESSAGE.ACTIONS_NAMESPACE_NOT_EXIST", HttpStatus.BAD_REQUEST),

    /**
     * 企业认证相关异常
     */
    ENTERPRISE_EXIST(4300,"统一社会信用代码已存在","MESSAGE.ENTERPRISE_EXIST",HttpStatus.BAD_REQUEST),
    ORG_ENTERPRISE_NOT_EXSIT(4301,"组织下不存在企业认证信息","MESSAGE.ORG_ENTERPRISE_NOT_EXSIT",HttpStatus.BAD_REQUEST),
    ORG_ENTERPRISE_CERTIFIED(4302,"组织已有企业认证","MESSAGE.ORG_ENTERPRISE_CERTIFIED",HttpStatus.BAD_REQUEST),
    IDCARD_RECOGNITION_ERROR(4303,"身份证识别失败","MESSAGE.IDCARD_RECOGNITION_ERROR",HttpStatus.BAD_REQUEST),
    BUSINESS_LICENSE_RECOGNITION_ERROR(4304,"营业执照识别失败","MESSAGE.BUSINESS_LICENSE_RECOGNITION_ERROR",HttpStatus.BAD_REQUEST),
    FILE_ERROR(4305,"文件资源上传失败","MESSAGE.FILE_ERROR",HttpStatus.BAD_REQUEST),
    ENTERPRISE_QUERY_ERROR(4306, "组织认证信息查询失败，暂无权限", "MESSAGE.ENTERPRISE_QUERY_ERROR", HttpStatus.BAD_REQUEST),
    ENTERPRISE_PIC_QUERY_ERROR(4307, "资源获取失败", "MESSAGE.ENTERPRISE_PIC_QUERY_ERROR", HttpStatus.BAD_REQUEST),
    ENTERPRISE_AUDITED(4308, "企业认证信息非审核状态，不可重复审核", "MESSAGE.ENTERPRISE_PIC_QUERY_ERROR", HttpStatus.BAD_REQUEST),
    ENTERPRISE_FILE_ERROR(4309, "文件格式不支持", "MESSAGE.ENTERPRISE_FILE_ERROR", HttpStatus.BAD_REQUEST),
    ENTERPRISE_CORPORATION_ERROR(4309, "企业法人和身份证名称不一致", "MESSAGE.ENTERPRISE_FILE_ERROR", HttpStatus.BAD_REQUEST),
    ;


    final int code;
    final String msg;
    final String i18n;
    final HttpStatus httpStatus;

    private static final Map<String, ResultCodeEnum> NAME_TO_CODE = Maps.newHashMap();

    static {
        for (ResultCodeEnum value : ResultCodeEnum.values()) {
            NAME_TO_CODE.put(value.name(), value);
        }
    }

    public static String format(ResultCodeEnum resultCodeEnum, String field) {
        return String.format(resultCodeEnum.getMsg(), field);
    }

    public static ResultCodeEnum getResultCode(String name) {
        return NAME_TO_CODE.getOrDefault(name, FAIL);
    }
}
